<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
    <meta name="renderer" content="webkit">
    <link href="${pageContext.request.contextPath}/static/css/common.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/plugins/layer/skin/layer.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/plugins/bootstrap-3.3.5/css/bootstrap.min.css"
          rel="stylesheet">
          <link href="${pageContext.request.contextPath}/static/plugins/select2-4.0.0/dist/css/select2.min.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/plugins/font-awesome-4.3.0/css/font-awesome.min.css"
          rel="stylesheet">
          <link rel="stylesheet" href="${pageContext.request.contextPath}/static/plugins/jquery.time/jquery.timepicker.min.css">
    <script src="${pageContext.request.contextPath}/static/js/jquery-1.11.3.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/plugins/bootstrap-3.3.5/js/bootstrap.min.js"></script>
    <script src="/static/plugins/bootstrap-3.3.5/js/bootstrap.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/plugins/layer/layer.js" type="text/javascript"></script>
	<script src="${pageContext.request.contextPath}/static/plugins/select2-4.0.0/dist/js/select2.min.js"></script>
	<script src="${pageContext.request.contextPath}/static/plugins/My97DatePicker/WdatePicker.js"
        type="text/javascript"></script>
	<script src="${pageContext.request.contextPath}/static/plugins/jquery.time/jquery.timepicker.min.js"
        type="text/javascript"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/static/js/global.js"></script>
    <style type="text/css">
        .show_seletor {
            border: 1px solid #EEE;
            padding: 3px;
            background: #337ab7;
            line-height: 20px;
            color: #FFF;
            display: inline-block;
            margin-right: 5px;
        }
        .labe{
        	margin-left: 8px;
        }
        .lt,.col-sm-3,.col-sm-8{float:left}
		.form-group,.col-sm-2{*+overflow:hidden;}
		.form-group label{width:16%\9;*+width:16%;text-align:right\9;*+text-align:right;}
		.col-sm-8 .m-t2 {width:30%\9; *+width:36%;}
		.col-sm-8 textarea{*+width:98%;}
		.form-group .col-sm-8{width:66%\9;*+width:63%;}
		.form-group .form-control{*+width:95%;}
		.form-control{*+height:22px;}
		#sub{*+margin-right:10px;}
		.input-group .form-control{*+z-index:-1;}
		.form-group .form-control{*+line-height:22px;}
		.upload{*+position:relative;}
		.btn-primary{*+position:absolute;*+left:431px;*+top:-35px;*+z-index:3;}
		.m-t2  label{width:62px\9;*+width:64px;}
		.col-sm-8 .input-group{width:500px;lwidth:494px\9;}
		.input-group .col-md-1{width:44%;width:100%\9;*+width:38%;float:left;*+height:22px;*+line-height:22px;}
		.input-group .input-group-addon{width:36px;width:36px\9;*+width:36px;height:34px;height:34px\9;line-height:22px;line-height:22px\9;*+height:22px;*+line-height:22px;}
    </style>
    </style>
</head>
<body style="overflow-x: hidden">
<div class="col-sm-12">
    <form class="form-horizontal m-t" method="post" id="form"
          action="${pageContext.request.contextPath}/admin/bannerStrategy_edit.action">
         <input type="hidden" value="${map.sid}" name="sid">
         <input type="hidden" value="${map.shelvesid}" name="shid">
         <input type="hidden" value="${map.enabledflag}" name="enabledflag">
         <input type="hidden" value="${agt}" name="agtCode">
          <a id="sure" onclick="sure()" hidden="true"></a>
        <div class="form-group">
            <label class="col-sm-3 col-sm-3 control-label">资源名称:</label>
            <div class="col-sm-8">
                <input class="form-control" name="cName" size="30" value="${map.cName}" disabled="disabled"/>
            </div>
        </div>
         <div class="form-group">
                <label class="col-sm-3 col-sm-3 control-label">资源类型:</label>
                <div class="col-sm-8">
                    <select class="form-control" name="type" id="type" disabled="disabled">
                        <option value="1">图片</option>
                        <option value="2">h5链接</option>
                    </select>
                </div>
            </div>
         <div class="form-group">
            <label class="col-sm-3 col-sm-3 control-label">URL:</label>
            <div class="col-sm-8">
                <input class="form-control" name="cUrl" size="30" value="${map.cUrl}" disabled="disabled"/>
            </div>
        </div>
         <div class="form-group">
            <label class="col-sm-3 col-sm-3 control-label">结算方式:</label>
            <div class="col-sm-8">
                <input class="form-control" name="settlementMethod" value="${map.settlementMethod}" disabled="disabled" size="30"/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 col-sm-3 control-label">预计收益:</label>
            <div class="col-sm-8">
                <input class="form-control" name="expectedIncome" value="${map.expectedIncome}" disabled="disabled" size="30"/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 col-sm-3 control-label">广告详情:</label>
            <div class="col-sm-8">
                <input class="form-control" name="adDetails" value="${map.adDetails}" disabled="disabled" size="30"/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 col-sm-3 control-label">上架者信息:</label>
            <div class="col-sm-8">
                <input class="form-control" size="30" value="操作者：${map.cUser1}；操作时间：${map.cTime1}" disabled="disabled"/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 col-sm-3 control-label">分配者信息:</label>
            <div class="col-sm-8">
            	<textarea rows="5" cols="80%" name="distribute" id="distribute" disabled="disabled" >${map.distribute}</textarea>
<!--                 <input class="form-control" size="30" name="distribute" id="distribute"  disabled="disabled"/> -->
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 col-sm-3 control-label">已分配范围:</label>
            <div class="col-sm-8">
<!--                 <input class="form-control" size="30" name="distributeRange" id="distributeRange"   disabled="disabled"/> -->
			<textarea rows="5" cols="80%" name="distributeRange" id="distributeRange" disabled="disabled" >${map.distributeRange}</textarea>
            </div>
        </div>
        
        
        <div class="form-group">
            <label class="col-sm-3 control-label"><i class="require">*</i>优先级:</label>
            <div class="col-sm-8">
                <c:if test="${ifChange == 'yes'}">
                	<select name="priority" id="priority" class="select2">
        		</c:if>
                <c:if test="${ifChange == 'no'}">
                	<select name="priority" id="priority" class="select2" disabled="disabled">
        		</c:if>
                    <option value="1">1</option>
                    <option value="2">2</option>
                    <option value="3">3</option>
                    <option value="4">4</option>
                    <option value="5">5</option>
                    <option value="6">6</option>
                    <option value="7">7</option>
                    <option value="8">8</option>
                    <option value="9">9</option>
                </select>
                
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3  control-label"><i class="require">*</i>显示日期:</label>
            <div class="col-sm-8">
                <div class="input-group">
                <c:if test="${ifChange == 'yes'}">
                    <input class="inputWhite form-control col-md-1 lt" name="timeFrom" id='timeFrom' readonly
                           onclick='WdatePicker()'/>
                    <div class="input-group-addon lt">至</div>
                    <input name='timeTo' id='timeTo' readonly
                           class="inputWhite form-control col-md-1 lt" onclick='WdatePicker()'/>
        		</c:if>
                <c:if test="${ifChange == 'no'}">
                    <input class="form-control col-md-1 lt" id='timeFrom' readonly
                           onclick='WdatePicker()' disabled="disabled"/>
                    <div class="input-group-addon lt">至</div>
                    <input id='timeTo' readonly
                           class="form-control col-md-1 lt" onclick='WdatePicker()' disabled="disabled"/>
                    <input class="form-control col-md-1 lt" name="timeFrom" id='timeFrom1' readonly
                           onclick='WdatePicker()' type="hidden"/>
                    <input name='timeTo' id='timeTo1' readonly type="hidden"
                           class="form-control col-md-1 lt" onclick='WdatePicker()' />      
        		</c:if>
                </div>
            </div>
        </div>
         <div class="form-group">
            <label class="col-sm-3 col-sm-3 control-label"><i class="require">*</i>广告位置:</label>
            <div class="col-sm-8">
	            <c:if test="${ifChange == 'yes'}">
	                <div class="col-sm-2 m-t2" style="width: 150px;" id="range1">
	                    <input type="checkbox" name="bannerPosition" id="banner1" size="30"  value="1"/><label class="labe">首页</label>
	                </div>
	                <div class="col-sm-2 m-t2" style="width: 150px;" id="range2">
	                    <input type="checkbox" name="bannerPosition" id="banner2" size="30" value="2"/><label class="labe">生活服务页</label>
	                </div>
	            </c:if>
	            <c:if test="${ifChange == 'no'}">
	                <div class="col-sm-2 m-t2" style="width: 150px;" id="range1">
	                    <input type="checkbox" id="banner1" size="30"  value="1" disabled="disabled"/><label class="labe">首页</label>
	                    <input type="checkbox" name="bannerPosition" id="banner3" size="30"  value="1" hidden="true"/>
	                </div>
	                <div class="col-sm-2 m-t2" style="width: 150px;" id="range2">
	                    <input type="checkbox" id="banner2" size="30" value="2" disabled="disabled" /><label class="labe">生活服务页</label>
	                    <input type="checkbox" name="bannerPosition" id="banner4" size="30" value="2" hidden="true" />
	                </div>
	            </c:if>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 col-sm-3 control-label">上架范围:</label>
            <div class="col-sm-8">
<!--                 <div class="col-sm-2 m-t2"> -->
<!--                     <input type="radio" name="range" size="30" value="0" checked="checked" /><label>全局</label> -->
<!--                 </div> -->
                <div class="col-sm-2 m-t2" style="width: 150px;" id="range1">
                    <input type="radio" name="range" size="30"  value="1"/><label>全部小区</label>
                </div>
                <div class="col-sm-2 m-t2" style="width: 150px;" id="range2">
                    <input type="radio" name="range"  size="30" value="2"/><label>部分小区</label>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">选择投放小区:</label>
            <div class="col-sm-8">
                <select id="communityId" name="communityId" multiple="multiple" disabled="disabled">
                </select>
            </div>
        </div>
    </form>
</div>
<script type="text/javascript">
	
    $(function () {
    	$("#type").val('${map.type}');
    	if('${map.banner_position}'.indexOf(',1,')>-1){
    		$("#banner1").attr("checked","checked");
    		$("#banner3").attr("checked","checked");
       	}
    	if('${map.banner_position}'.indexOf(',2,')>-1){
    		$("#banner2").attr("checked","checked");
    		$("#banner4").attr("checked","checked");
       	}
    	if('${map.priority}' !=''){
    		$("#priority").val('${map.priority}');
        }else{
        	$("#priority").val(1);
        }
        $(".select2").select2({
            minimumResultsForSearch: -1,
            width:'100%'
        });
        if('${map.timeFrom}' !=''){
        	$("#timeFrom").val('${map.timeFrom}'.substring(0,10) );
        	$("#timeFrom1").val('${map.timeFrom}'.substring(0,10) );
        }else{
        	$("#timeFrom").val(curDateTime);
        	$("#timeFrom1").val(curDateTime);
        }
        if('${map.timeTo}' !=''){
        	$("#timeTo").val('${map.timeTo}'.substring(0,10) );
        	$("#timeTo1").val('${map.timeTo}'.substring(0,10) );
        }else{
        	$("#timeTo").val(curDateTime);
        	$("#timeTo1").val(curDateTime);
        }
       
        $("input[name='range'][value=1]").attr("checked", true);
        $("#communityId").select2({
        	 minimumResultsForSearch: -1,
            placeholder: "请选择小区",
            width: "100%"
        })
        $('input:radio[name="range"]').change( function(){
        	var value = $("input[name='range']:checked").val();
            if(value == 1){
       			$("#communityId").attr("disabled", "true");
      			$("#communityId").empty();
          		$("#communityId").select2({
                      placeholder: "请选择小区",
                      width: "100%"
                 })
            }else{//单公司下部分小区
            	$("#communityId").removeAttr("disabled");
            	$("#communityId").empty();
            	addComuId('${agt}');
            }
            
        	
        });
        
    });
	function addComuId(agtCodes){
		var arr='';
		if('${map.agtHaveDistribute}'!=''){
			var comm = '${map.agtHaveDistribute}';
			arr = comm.split(",");
		}
		 $.post("${pageContext.request.contextPath}/admin/tcommunity_listByAgtCodes.action?agtCodes="+agtCodes, function (result) {
	           $("#communityId").empty();
	           $("#communityId").append("<option value=''>请选择小区</option>");
	            for (var i = 0; i < result.length; i++) {
	            	var u;
					if(arr != ''){
		            	u=arr.indexOf(result[i].sid.toString());
		            	if(u != -1){
		                	continue;
		                }
					}
	                $("#communityId").append("<option value='" + result[i].sid + "'>" + result[i].communityName + "</option>");
	            }
	            $("#communityId").select2({
	                placeholder: "请选择小区",
	                width: "100%"
	            })
	       }, "json");
	}
</script>
</body>
</html>
